#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int findNumberOfLIS(vector<int>& nums) {
    int n = nums.size();
    vector<int> f(n + 1, 1), g(n + 1, 1);
    int nmax = 1;
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < i; j++)
            if (nums[j] < nums[i])
            {
                if (f[i] == f[j] + 1)
                    g[i] += g[j];
                else if (f[i] < f[j] + 1)
                {
                    f[i] = f[j] + 1;
                    g[i] = g[j];
                }
            }
        nmax = max(f[i], nmax);
    }
    for (int i = 0; i < n; i++)    cout << g[i] << " ";
    int res = 0;
    for (int i = 0; i < n; i++)
        if (f[i] == nmax)
            res += g[i];
    return res;
}

int findLongestChain(vector<vector<int>>& pairs) {
    int n = pairs.size();
    sort(pairs.begin(), pairs.end());
    vector<int> f(n, 1);
    int res = 1;
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < i; j++)
            if (pairs[j][1] < pairs[i][0])
                f[i] = max(f[i], f[j] + 1);
        res = max(res, f[i]);
    }
    return res;
}